package com.atwisdom.star.serviceController.specification;

import com.alibaba.fastjson.JSONObject;
import com.atwisdom.star.common.vo.ResultInfo;
import com.atwisdom.star.exception.pojo.BusinessException;
import com.atwisdom.star.log.aop.StarAnnotation;
import com.atwisdom.star.service.specification.SpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: EquipPointServiceController
 * @ Description:   产品规格工艺参数
 * @author: wjj
 * @date: 2024/7/19
 */
@RestController
@RequestMapping("/specification")
public class SpecificationServiceController {

    @Autowired
    private SpecificationService specificationService;


    /**
     * 1.根据产品id查询产品规格logic容器存在返回不存在新增
     * 2.同步采集点信息到工艺参数
     */
    @StarAnnotation
    @PostMapping("/querySpecificationByProductId")
    public ResultInfo<?> querySpecificationByProductId(@RequestBody JSONObject data) throws BusinessException {
        return specificationService.querySpecificationByProductIdAndSync(data);
    }

    /**
     * 新增工艺参数并加入产品规格容器
     */
    @StarAnnotation
    @PostMapping("/addTechnologyParams")
    public ResultInfo<?> addTechnologyParams(@RequestBody JSONObject data) throws BusinessException {
        return specificationService.addTechnologyParams(data);
    }

    /**
     * 根据产品id查询实验室参数组容器存在返回不存在新增
     */
    @StarAnnotation
    @PostMapping("/queryLaboratoryByProductId")
    public ResultInfo<?> queryLaboratoryByProductId(@RequestBody JSONObject data) throws BusinessException {
        return specificationService.queryLaboratoryByProductId(data);
    }

    /**
     * 新增实验室参数并加入实验室参数组容器
     */
    @StarAnnotation
    @PostMapping("/addLaboratoryParams")
    public ResultInfo<?> addLaboratoryParams(@RequestBody JSONObject data) throws BusinessException {
        return specificationService.addLaboratoryParams(data);
    }

    /**
     * 品规下是否有工艺参数或实验室参数实体
     */
    @StarAnnotation
    @PostMapping("/isProductHasContent")
    public ResultInfo<?> isProductHasContent(@RequestBody JSONObject data) throws BusinessException {
        return specificationService.isProductHasContent(data);
    }
}